package com.ofood.springcloud.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateTimeUtils {
    private static final String PATTERN="YYYY/MM/dd HH:mm:ss";

    public static String convertLocalTimeToString(LocalDateTime localTime){
        if(localTime!=null) {
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN);
            return localTime.format(formatter);
        }

        return "";
    }

    public static LocalDateTime convertStringToLocalDateTime(String value){
        LocalDateTime localDateTime=LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN);
        localDateTime=LocalDateTime.parse(value,formatter);
        return localDateTime;
    }
}
